import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import RecipientControl from "@/views/home_childrenpage/RecipientControl";
import SenderControl from "@/views/home_childrenpage/SenderControl";
import Welcome from "@/views/home_childrenpage/Welcome";
import AboutProject from "@/components/AboutProject";
import AppDownload from "@/components/AppDownload";
import Help from "@/components/Help";
import MailTemplate from "@/views/home_childrenpage/MailTemplate";
import SendEmail from "@/views/home_childrenpage/SendEmail";

//解决路径重复打开的报错提示
/*const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err);
}*/

Vue.use(VueRouter);

const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home,
        children: [
            {
                path: '/',
                name: '欢迎页',
                component: Welcome,
                children: [
                    {
                        path: '/AboutProject',
                        name: '关于项目',
                        component: AboutProject
                    },
                    {
                        path: '/AppDownload',
                        name: '安卓端下载',
                        component: AppDownload
                    },
                    {
                        path: '/Help',
                        name: '帮助手册',
                        component: Help
                    }
                ]
            }, {
                path: '/RecipientControl',
                name: '收件人管理',
                component: RecipientControl
            }, {
                path: '/SenderControl',
                name: '发件人管理',
                component: SenderControl
            }, {
                path: '/MailTemplate',
                name: '编辑邮件模板',
                component: MailTemplate
            }, {
                path: '/SendEmail',
                name: '发送邮件',
                component: SendEmail,
                props: route => ({query: route.query.filterBox})
            }
        ]
    }
]
const router = new VueRouter({
    routes
})
//前端路由前置守卫
router.beforeEach((to, from, next) => {
    next();
})
export default router